package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author lcm
 * @since 2023-07-28
 */
@RestController
@RequestMapping("/likes")
@Api(tags = "点赞相关接口")
@RequiredArgsConstructor
public class LikedRecordController {
    private final ILikedRecordService likedRecordServiceService;

    @PostMapping
    @ApiOperation("新增或撤销点赞")
    public void addOrRemoveLike(@ApiParam("点赞表单数据") @Valid @RequestBody LikeRecordFormDTO likeRecordFormDTO){
        likedRecordServiceService.addOrRemoveLike(likeRecordFormDTO);
    }

    @GetMapping("list")
    @ApiOperation("批量查询点赞状态")
    public Set<Long> queryBatchLikesStatus(@RequestParam("bizIds") List<Long> bizIds){
        return likedRecordServiceService.queryBatchLikesStatus(bizIds);
    }
}
